﻿// ActionScript file
package org.nickro.utils{
	public class XMLUtil
	{
		private var newXMLList:XMLList;
		public function XMLUtil(source:XML)
		{
			newXMLList = source.length();
		}
		public function addItem(item:XML):XMLList
		{
			newXMLList += item;
			return newXMLList;
		}
		public function addItemAt(item:XML,index:int):XMLList
		{
			
		}
		public function removeItemAt(index:int):XMLList
		{
			delete newXMLList[index];
		}
		public function slice(startIndex:int,endIndex:int):XMLList
		{
			/**
			 * !!注意:在循环更迭的过程中，XMLList文件会因为改变文件结构而造成xmlList.length()发生改变
			 */
			for(var i:int = 0 ; i< newXMLList.length(); i++)
			{
				if( i < startIndex )
				{
					delete xmlList[0];
				}
				if( i > endIndex )
				{
					//在endIndex - startIndex + 1�?循环删除mainNum - endIndex�?
					delete xmlList[endIndex - startIndex + 1];
				} 
			}
			return xmlList;
		}
	}
}